package cn.kgc.shiro.web.handlers;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 课工场
 * @date 2024/12/6
 * @description
 */
@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(AuthorizationException.class)
    public Map<String,Object> authorizationExceptionHandler(AuthorizationException e){

        e.printStackTrace();

        HashMap<String, Object> result = new HashMap<>();
        result.put("code",403);
        result.put("message","没有权限请联系管理员");
        return  result;
    }
}
